package com.ExaminStudy;
import java.util.Scanner;

public class Test3_12_9 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入一段字符");
        String s=sc.nextLine();
        TongJi(s);
    }

    private static void TongJi(String s) {
        char[]chars = s.toCharArray();
        int character=0;
        int letter=0;
        int space=0;
        int other=0;
        for (int i = 0; i < chars.length; i++) {
            if(chars[i]>='a'&&chars[i]<='z'||chars[i]>='A'&&chars[i]<='Z'){
                letter++;
            }else if(chars[i]==' '){
                space++;
            } else if (chars[i]>='0'&&chars[i]<='9') {
                character++;

            }else {
                other++;
            }

        }
        System.out.println("字母有"+letter+"空格有"+space+"数字有"+character+"其他字符有"+other);

    }

}
